// 抽象工厂--开放封闭原则

class MobilePhoneFactory {
    createOs() {
        throw new Error('抽象工厂方法不允许直接调用')
    }

    createHardWare() {
        throw new Error('抽象工厂方法不允许直接调用')
    }
}

// new MobilePhoneFactory().createOs()

class OS {
    controlHardWare() {
        throw new Error('抽象工厂方法不允许直接调用')
    }
}

class IOS {
    controlHardWare() {
        throw new Error('抽象工厂方法不允许直接调用')
    }
}

class Androids extends OS {
    controlHardWare() {
        console.log('我会用安卓的方式打印硬件');
    }
}

class Apple extends IOS {
    controlHardWare() {
        console.log('我会用苹果的方式打印硬件');
    }
}

class HardWare {
    operateByOrder() {
        throw new Error('抽象工厂方法不允许直接调用')
    }
}

class QualcommHardWare extends HardWare {
    operateByOrder() {
        console.log('我会用高通的方式运行');
    }
    
}

class WnStarFactory extends MobilePhoneFactory {
    createOs() {
        return new Androids()
    }

    createHardWare(){
        return new QualcommHardWare()
    }

}

// 我的手机
const myPhone = new WnStarFactory()
const myHardWare = myPhone.createHardWare()
const myOS = myPhone.createOs()

myOS.controlHardWare()
